﻿using System.Text;

namespace Framework
{
    public static class GameConfig
    {
        #region  加密相关
        private static string defaultVectorKey = @"!_#@2022_Skyfly)";
        internal static void SetDefaultVectorKey(string newKey)
        {
            _keyVector = null;
            defaultVectorKey = newKey;
        }
        /// <summary>
        /// 加密向量,支持32、34、16字节
        /// </summary>
        private static byte[] _keyVector;
        public static byte[] AESKeyVector
        {
            get
            {
                if (null == _keyVector)
                {
                    _keyVector = new byte[16];
                    System.Array.Copy(Encoding.UTF8.GetBytes(defaultVectorKey.PadRight(_keyVector.Length)), _keyVector, _keyVector.Length);
                }
                return _keyVector;
            }
        }
        private static string defaultPasswordKey = @"@_#*&Reverse2806";
        internal static void SetDefaultPasswordKey(string newKey)
        {
            _password = null;
            defaultPasswordKey = newKey;
        }

        /// <summary>
        /// 加密密码，支持32、34、16字节
        /// </summary>
        private static byte[] _password;
        public static byte[] AESPassword
        {
            get
            {
                if (null == _password)
                {
                    _password = new byte[32];
                    System.Array.Copy(Encoding.UTF8.GetBytes(defaultPasswordKey.PadRight(_password.Length)), _password, _password.Length);
                }
                return _password;
            }
        }
        /// <summary>
        /// 资源解密公钥
        /// </summary>
        private static string defaultPublicKey = 
        #if !UNITY_EDITOR 
            @"<RSAKeyValue><Modulus>lqlSywySAeANv8iLKwb7/6R4YM7FHt6KLPILqrQXfWctVauiMdj2TzE96dN1hBqt</Modulus><Exponent>AQAB</Exponent></RSAKeyValue>";
        #else
            @"<RSAKeyValue><Modulus>kLm/rL5q/8iRO56CeH5jnBzJu7dj9XmcvX8n5Z5w/b5fvA9tOJVfaBKPZW666jvp</Modulus><Exponent>AQAB</Exponent></RSAKeyValue>";
        #endif
        public static string RsaPublicKey
        {
            internal get => defaultPublicKey;
            set => defaultPublicKey = value;
        }
        #endregion
    }
}